<!DOCTYPE html>
<html>
<head>
    <title>Simple app</title>

    <script type="text/javascript" src="lib/angular.js"></script>
    <script type="text/javascript">
        var app = angular.module("app",[]);
        app.controller('ParentController', function($scope) {
            $scope.person = {greeted: false};
        });
        app.controller('ChildController', function($scope) {
            //the parent of the ChildController’s $scope object will be the ParentController’s $scope object
            //child控制器的$scope的Parent就是parent控制器的$scope
            $scope.sayHello = function() {
                //child的$scope没有person。去parent中找,直到找到最顶层的$rootScope
                $scope.person.name = "Ari Lerner";
                $scope.person.greeted = true;
            }
        });
    </script>
</head>
<body ng-app="app">
<div ng-controller="ParentController">
    <div ng-controller="ChildController">
        <a ng-click="sayHello()">Say hello</a>
    </div>
    {{ person }}
</div>


</body>
</html>